﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FoundationLib.AddIns.Constrains.Test
{
	public static class TestDataFactory
	{
		public static SortedList<int, TestTuple> CreateTestData()
		{
			SortedList<int, TestTuple> tuples = new SortedList<int, TestTuple>();

			tuples.Add(1, new TestTuple { Input = "self.transactions->notEmpty()", Expected = "this.transactions.Count() > 0" });
			tuples.Add(2, new TestTuple { Input = "self.transactions->first().Amount > 0", Expected = "this.transactions.First().Amount > 0" });
			tuples.Add(3, new TestTuple { Input = "self.transactions->includesAll(other.Transactions)", Expected = "this.transactions.Where(x => other.Transactions.Contains(x)).Count() == other.Transactions.Count()" });
			tuples.Add(4, new TestTuple { Input = "self.transactions->includes(tran)", Expected = "this.transactions.Contains(tran)" });
			tuples.Add(5, new TestTuple { Input = "self.transactions->excludes(tran)", Expected = "!this.transactions.Contains(tran)" });
			tuples.Add(6, new TestTuple { Input = "self.transactions->count(tran)", Expected = "this.transactions.Where(x => x == tran).Count()" });
			tuples.Add(7, new TestTuple { Input = "self.transactions->union(other.Transactions)", Expected = "this.transactions.Union(other.Transactions)" });
			tuples.Add(8, new TestTuple { Input = "self.transactions->select(x | x.Balance > 100.0)->size() >= 1", Expected = "this.transactions.Where(x => x.Balance > 100.0).Count() >= 1" });
			tuples.Add(9, new TestTuple { Input = "self.transactions->sortedBy(x | x.Balance)", Expected = "this.transactions.OrderBy(x => x.Balance)" });
			tuples.Add(10, new TestTuple { Input = "self.transactions->sum(x | x.Balance) > 1000.0", Expected = "this.transactions.Sum(x => x.Balance) > 1000.0" });
			tuples.Add(11, new TestTuple { Input = "self.transactions->forAll(x | x.Balance > 0.0)", Expected = "Contract.ForAll(this.transactions, x => x.Balance > 0.0)" });
			tuples.Add(12, new TestTuple { Input = "self.transactions->exists(x | x.Balance = 0.0)", Expected = "Contract.Exists(this.transactions, x => x.Balance == 0.0)" });
			tuples.Add(13, new TestTuple { Input = "result > 0", Expected = "Contract.Result<string[]>() > 0", ReturnIsArray = true });
			tuples.Add(14, new TestTuple { Input = "self.transactions->first().Balance@pre > 0", Expected = "Contract.OldValue(this.transactions.First().Balance) > 0" });
			tuples.Add(15, new TestTuple { Input = "self.transactions->last().Balance > 0 and self.transactions->size() > 0", Expected = "this.transactions.Last().Balance > 0 && this.transactions.Count() > 0" });
			tuples.Add(16, new TestTuple { Input = "self.account.Owner.Name.First.concat(self.account.Owner.Name.Last)", Expected = "String.Concat(this.account.Owner.Name.First, this.account.Owner.Name.Last)" });
			tuples.Add(17, new TestTuple { Input = "self.account.Description.notEmpty()", Expected = "!String.IsNullOrWhitespace(this.account.Description)" });
			tuples.Add(18, new TestTuple { Input = "Date::now < self.transactions->first().Date", Expected = "DateTime.Now < this.transactions.First().Date" });
			tuples.Add(19, new TestTuple { Input = "self.account.Owner.Name.First.size() < 100", Expected = "this.account.Owner.Name.First.Length < 100" });
			tuples.Add(20, new TestTuple { Input = "self.account.Owner.Name.First <> \"Test\"", Expected = "this.account.Owner.Name.First != \"Test\"" });
			return tuples;
		}
	}
}
